package com.hex.ds.hdrs.common.constant;

/**
 * @author lwz
 * @date 2020-12-29
 * @des b
 */
public enum DispatcherStrategy {
    DS_1("1", "按优先级顺序"),
    DS_2("2", "按优先级且资源数顺序,资源数由大到小"),
    DS_3("3", "按优先级且资源数顺序,资源数由小到大"),
    DS_4("4", "按下游依赖数量"),
    DS_5("5", "按下一级依赖数量"),
    DS_6("6", "按时间最早先执行"),
    ;

    public String getCode() {
        return code;
    }

    private void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    private void setMessage(String message) {
        this.message = message;
    }

    /**
     * 根据code获取去value
     *
     * @param code
     * @return
     */
    public static String getValueByCode(String code) {
        for (DispatcherStrategy dispatcherStrategy : DispatcherStrategy.values()) {
            if (code.equals(dispatcherStrategy.getCode())) {
                return dispatcherStrategy.getMessage();
            }
        }
        return null;
    }

    private String code;
    private String message;

    private DispatcherStrategy(String code, String message) {
        this.code = code;
        this.message = message;
    }
}
